<?php
/**
 * --------------------------------------------------------------
 * admin已登录入口模型
 * Author: zd <kfzphp@126.com>
 * Date: 2018-06-01
 * Project: kfzphp.com
 * --------------------------------------------------------------
 */

class EntryModel extends AdminModel
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取配置总数
     * @return [type]            [description]
     */
    public function getConfigCount()
    {
        $sql = 'select count(id) from ' . T('config');
        return $this->mysql->getOne($sql);
    }

    /**
     * 新增配置
     * @param  [type]     $data [description]
     * @return [type]           [description]
     */
    public function insertConfig($data)
    {
        return $this->mysql->insert(T('config'), $data);
    }

    /**
     * 修改配置
     * @since  2018-04-02
     * @return [type]     [description]
     */
    public function updateConfig($data)
    {
        return $this->mysql->update(T('config'), $data, 'id = 1');
    }

    /**
     * 获取配置字段
     * @param  [type]     $where [description]
     * @return [type]            [description]
     */
    public function getConfigField($field)
    {
        $sql = 'select ' . $field . ' from ' . T('config') . ' limit 1';
        return $this->mysql->getOne($sql);
    }

}
